import { lazy, Suspense } from "react";
import { Navigate } from "react-router-dom";
import MyLoading from '../components/loading'
let Home = lazy(() => import('../views/Home'));
let Info = lazy(() => import('../views/Info'));
let Index = lazy(() => import('../views/Index'));
let Cart = lazy(() => import('../views/Cart'));
let Mine = lazy(() => import('../views/Mine'));
let Login = lazy(() => import('../views/Login'));
let ConfirmOrder = lazy(() => import('../views/confirmOrder'))
let Userprofile = lazy(() => import('../views/userprofile'))
let Search = lazy(() => import('../views/Search'))
let AddAddress  = lazy(()=>import('../views/addAddress'))
let Address  = lazy(()=>import('../views/Address'))

let element = [
    {
        path: "/index",
        element: <Suspense fallback={<MyLoading />}><Index /></Suspense>,
        author: false,
        children: [
            {
                path: "home",
                element: <Suspense fallback={<MyLoading />}><Home /></Suspense>,
                author: false
            }, {
                path: "cart",
                element: <Suspense fallback={<MyLoading />}><Cart /></Suspense>,
                author: true
            }, {
                path: "mine",
                element: <Suspense fallback={<MyLoading />}><Mine /></Suspense>,
                author: true
            }
        ]
    },
    {
        path: "/info/:id",
        element: <Suspense fallback={<MyLoading />}><Info /></Suspense>,
        author: false
    }, {
        path: "/login",
        element: <Suspense fallback={<MyLoading />}><Login /></Suspense>,
        author: false
    }, {
        path: "/",
        element: <Navigate to="/index/home"></Navigate>
    }, {
        path: "/conorder",
        element: <Suspense fallback={<MyLoading />}><ConfirmOrder /></Suspense>,
        author: true
    }, {
        path: "/userprofile",
        element: <Suspense fallback={<MyLoading />}><Userprofile /></Suspense>,
        author: true
    }, {
        path: "/search",
        element: <Suspense fallback={<MyLoading />}><Search /></Suspense>,
        author: true
    },{
        path:"/address",
        element:<Suspense fallback={<MyLoading/>}><Address/></Suspense>,
        author:true
    },{
        path:"/add",
        element:<Suspense fallback={<MyLoading/>}><AddAddress/></Suspense>,
        author:true
    }
]

export default element;